<admintpl file="header" />
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:U('Promoters/index')}" target="_self">内部推广人员</a></li>
        <li class="active"><a href="javascript:;" target="_self">添加</a></li>
    </ul>
    <form class="form-horizontal js-ajax-form" method="post" action="{:U('Promoters/add')}">
        <fieldset>
            <div class="control-group">
                <label class="control-label" for="input-user_name"><span class="form-required">*</span>姓名</label>
                <div class="controls">
                    <input type="text" id="input-user_name" name="user_name"  >
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="input-phone_mob"><span class="form-required">*</span>手机号</label>
                <div class="controls">
                    <input type="text" id="input-phone_mob" name="phone_mob"  >
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="input-store_name"><span class="form-required">*</span>职务</label>
                <div class="controls">
                    <input type="text" id="input-store_name" name="post" >
                </div>
            </div>
            <div class="form-actions">
                <button type="submit" class="btn btn-primary js-ajax-submit" id="lc-btn-save">{:L('SAVE')}</button>
                <a class="btn btn-primary" href="javascript:history.back(-1)">返回上一页</a>

            </div>
        </fieldset>
    </form>
</div>
<script src="__PUBLIC__/js/common.js"></script>
<script src="__PUBLIC__/layer/layer.js"></script>
<script>
    $("#lc-btn-save").click(function(){
        var user_name = $("input[name=user_name]").val();
        var phone_mob = $("input[name=phone_mob]").val();
        var post = $("input[name=post]").val();
        if(user_name == ''){
            layer.msg('请填写姓名！');
            return false;
        }
        if(phone_mob == ''){
            layer.msg('请输入手机号！');
            return false;
        }
        if(!/^1[3|4|5|7|6|8|9]\d{9}$/.test(phone_mob)){
            layer.msg('手机号不正确');
            return false;
        }
        var url = "{:U('Promoters/add')}";
        $.post(url,{
            user_name:user_name,
            phone_mob:phone_mob,
            post:post
        },function(data){
            var res = JSON.parse(data);
            if(res.code == 1){
                layer.msg(res.msg,function(){
                    window.location.reload();
                });
            }else{
                layer.msg(res.msg);
            }
        })
    });
</script>
</body>
</html>
